/**
 * Created by WYH on 17/4/23.
 */
angular.module('lockDelete', []).component(
    'lockDelete',
    {
        templateUrl: 'component/lock/lockDelete/lock_delete.template.html',
        controller: [
            '$scope', 'Api','Alert',
            function ($scope, Api,Alert) {

                $scope.submitDeleteLock = submitDeleteLock;

                function callDeleteLockService() {
                    Api.deleteLock($scope.$parent.selectedLock.id, function (result) {
                        Alert.alertBox('删除成功',function () {
                          return window.location.reload();
                        });
                    })
                }

                function submitDeleteLock() {
                    if ($scope.confirmSelectName != $scope.$parent.selectedLock.name) {
                        Alert.alertBox('输入的设备名称不正确');
                    } else {
                        callDeleteLockService();
                    }

                }
            }
        ]
    }
);